﻿using System;
using System.Windows.Forms;
using SneakyWeasel.Engine;

namespace SneakyWeasel
{
    class SWPluginSuppressKeys : SWPlugin
    {
        public override void OnStart(ISWEngine sw, Form f)
        {
            sw.swForm.KeyDown += new KeyEventHandler(this.SuppressKey);
            f.KeyPress += new KeyPressEventHandler(this.HandleKeyPress);
        }

        public override void OnStop(ISWEngine sw, Form f)
        {
            f.KeyDown -= new KeyEventHandler(this.SuppressKey);
            f.KeyPress -= new KeyPressEventHandler(this.HandleKeyPress);
        }

        private void HandleKeyPress(object sender, KeyPressEventArgs e)
        {
            e.Handled = true;
        }

        private void SuppressKey(object sender, KeyEventArgs e)
        {
            e.SuppressKeyPress = true;
        }
    }
}
